<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>$Title$</title>
    <script src="../static/js/jquery-1.8.2.min.js"></script>
    <link rel="stylesheet" href="../static/css/css.css">
</head>
<body>
<form action="add" method="post">
    <table>
        <tr>
            <td>用户名</td>
            <td>
                <input type="text" name="userName">
            </td>
        </tr>
        <tr>
            <td>密码</td>
            <td>
                <input type="password" name="password">
            </td>
        </tr>
        <tr>
            <td>真实姓名</td>
            <td>
                <input type="text" name="trueName">
            </td>
        </tr>
        <tr>
            <td>电子邮件</td>
            <td>
                <input type="text" name="email">
            </td>
        </tr>
        <tr>
            <td>联系电话</td>
            <td>
                <input type="text" name="phone">
            </td>
        </tr>
        <tr>
            <td>备注</td>
            <td>
                <input type="text" name="comments">
            </td>
        </tr>
        <tr>
            <td>性别</td>
            <td>
                <input type="radio" name="sex" value="男">男
                <input type="radio" name="sex" value="女">女
            </td>
        </tr>
        <tr>
            <td>爱好</td>
            <td>
                <input type="checkbox" name="love" value="篮球">篮球
                <input type="checkbox" name="love" value="足球">足球
                <input type="checkbox" name="love" value="乒乓球">乒乓球
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="button" value="注册" onclick="add()" >
            </td>
        </tr>
    </table>
</form>
</body>
<script>

    function add() {
        $.ajax({
            url:"/add",
            type:"post",
            data:$("form").serialize(),
            dataType:"json",
            success:function (obj) {
                if (obj==1) {
                    alert("添加成功");
                    location = "/list";
                }else {
                    alert("添加失败！");
                }
            }
        })
    }
</script>
</html>